package org.xiaojun.vueclidemo.controller;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xiaojun.vueclidemo.pojo.Emp;

import java.util.Objects;

/**
 * @author xj
 * @create 2021/8/25 11:09
 */
@Controller
@CrossOrigin
public class EmpCntroller {

    @ResponseBody
    @RequestMapping("/login")
    public String login(@RequestBody Emp employee){

        Emp emp = new Emp();
        emp.setId(1);
        emp.setEmpName("张三");
        emp.setAge(22);
        emp.setSalary(3333f);

        Emp emp1 = new Emp();
        emp1.setId(2);
        emp1.setEmpName("李四");
        emp1.setAge(33);
        emp1.setSalary(2222f);

        if (Objects.equals(employee.getEmpName(), emp.getEmpName())){
            return "success";
        }

        if (Objects.equals(employee.getEmpName(), emp1.getEmpName())){
            return "success";
        }

        return "error";

    }
}
